cmake_minimum_required(VERSION 3.8)
project(ubt_trajectory_track)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

# ---------------------------------------------------------<


find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(ubt_interface REQUIRED)
find_package(ubt_com REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(OpenMP REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)

find_package(dynamic_reconfigure REQUIRED)


add_library(ubt_trajectory_tracking_pkg
 src/common/TrajectoryTracking.cpp
 src/common/TrajectoryTracking_mag.cpp
 src/common/TrajectoryTrackingTruck.cpp
 src/control/control.cpp
 src/control/control_mag.cpp
 src/control/control_truck.cpp
 src/common/pid_control.cpp
)

target_include_directories(ubt_trajectory_tracking_pkg PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)

target_link_libraries(ubt_trajectory_tracking_pkg 
      fmt
      yaml-cpp
)
ament_target_dependencies(ubt_trajectory_tracking_pkg
  rclcpp
  std_msgs
  ubt_interface
  ubt_com
  geometry_msgs
  nav_msgs
  visualization_msgs
  tf2_ros
  tf2
  dynamic_reconfigure
)


add_executable(control_node src/control_node.cpp)
target_include_directories(control_node PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)
target_link_libraries(control_node 
      ubt_trajectory_tracking_pkg
)


add_executable(control_node_truck src/control_node_truck.cpp)
target_include_directories(control_node_truck PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)
target_link_libraries(control_node_truck 
      ubt_trajectory_tracking_pkg
)


add_executable(control_node_mag src/control_node_mag.cpp)
target_include_directories(control_node_mag PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)
target_link_libraries(control_node_mag 
      ubt_trajectory_tracking_pkg
)


install(TARGETS 
    ubt_trajectory_tracking_pkg control_node control_node_mag control_node_truck
    RUNTIME DESTINATION lib/${PROJECT_NAME}
    LIBRARY DESTINATION lib/${PROJECT_NAME}
    ARCHIVE DESTINATION lib/${PROJECT_NAME}
)
# --------------------------------------------------------->

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
